'use strict';
module.exports = {
	/**
	 * XXXnameXXX
	 * @url agent/callback/pub/qimaoCallback 前端调用的url参数地址
	 * data 请求参数
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		let {
			data = {}, userInfo, util, filterResponse, originalParam
		} = event;
		let {
			customUtil,
			uniID,
			config,
			pubFun,
			vk,
			db,
			_
		} = util;
		let {
			uid,
			advertiserid, //广告主id
			cid, //广告计划id
			crid, //广告创意id
			ip,
			callback,
			tfid,
			invite_code
		} = data;
		let res = {
			code: 0,
			msg: ""
		};
		// 业务逻辑开始-----------------------------------------------------------
		// let request_id = vk.pubfn.getUniCloudRequestId();
		// let look_log = await db.collection('vk-test').add({
		// 	tips: "查看七猫回传",
		// 	request_id: request_id,
		// })
		// console.log("111",callback);
		var time = new Date().getTime()
		if (callback) {
			let addchudian = await db.collection('jl_chudian').add({
				pt: "qimao", //平台
				tfid: tfid || 0,
				invite_code: invite_code || 0,
				uid: uid || 0,
				ad_id: advertiserid || 0,
				cid: cid || 0,
				aid: crid || 0,
				ip: ip || 0,
				callback: callback || 0,
				time: time || 0,
				time_str: vk.pubfn.timeFormat(new Date(), "yyyy-MM-dd hh:mm:ss") || 0
			})
		}

		res.context = originalParam.context


		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}